import { createSSRApp } from 'vue';
import App from './App.vue';
import { $http } from '@escook/request-miniprogram';

// 配置 $http
const app = createSSRApp(App);
uni.$http = $http; // 这种情况下可能不需要 uni.$http，使用 Vue.prototype.$http
$http.baseUrl = 'https://api-hmugo-web.itheima.net';
$http.beforeRequest = function (options) {
  uni.showLoading({
    title: "数据加载中..."
  });
};

$http.afterRequest = function () {
  uni.hideLoading();
};
// 封装获取接口数据失败
uni.$showMsg = function(title = '加载失败',duration = 1500){
	uni.showToast({
		title,
		duration,
		icon:'none'
	})
}

export function createApp() {
  return {
    app
  };
}
